/**************************
 * Project: ePoverty
 * Filename: Validator.java
 * Description: Checks to see if fields have a valid format.
 * Name: Bunna Veth
 * Date: Apr 9, 2012
 **************************/
package epoverty;

public class FieldValidator
{
    //Date
    public static boolean isValidDate(String value)
    {
        return value.matches("\\d{4}-[01]\\d-[0123]\\d"); //2012-04-20
    }

    //Zipcode
    public static boolean isValidZip(String value)
    {
        return value.matches("\\d{5}"); //84119
    }

    //Email
    public static boolean isValidEmail(String value)
    {
        return value.matches("\\S+@\\S+\\.\\S+"); //steve@gmail.com
    }

    //Dollar Amount
    public static boolean isValidAmount(String value)
    {
        boolean isInteger = value.matches("[1-9]\\d*"); //350
        boolean isDecimal = value.matches("[1-9]\\d*\\.\\d{2}"); //350.00

        return isInteger || isDecimal; //can be one or the either
    }

}//end class